/*
 * EventUser.cpp
 *
 *  Created on: Jun 2, 2010
 *      Author: sdaniele
 */


#include "EventUser.h"

namespace noti {

#define PREFIX ":" << sc_delta_count() << ":[" << sc_time_stamp() << "]:"

EventUser::EventUser(sc_module_name name, sc_event* event, const sc_clock* clk, bool is_thread)
	:sc_module(name), m_event(event), m_name(name), m_is_thread(is_thread)
{
	m_clk.bind(*clk);
}

EventUser::~EventUser(){}

mutex_t EventUser::mu_cout = mutex_t();

void EventUser::do_thread_work(){
	while(true){
		do_method_work();
		wait();
	}
}


void EventUser::do_method_work(){
	print_report();
}

void EventUser::print_report() const {
#       if 0
        mutex_t::scoped_lock lock(mu_cout);
	::std::cout << this->report();
#       endif
}

::std::string EventUser::report() const {
	::std::stringstream s;
	s << PREFIX << m_name << " is running ok" << ::std::endl;
	return s.str();
}

}
